from datetime import datetime

from pydantic import Field
from typing import Optional, Annotated, List

from ...base import BaseApiListOut, BaseSchema, BaseApiOut


class GoodBase(BaseSchema):
    code: Optional[str] = Field(None, description='商户编码')
    brand_id: Optional[int] = Field(None, description='品牌编码')
    title: Optional[str] = Field(None, description='标题')
    order_id: Optional[str] = Field(None, description='订单号')
    desc: Optional[str] = Field(None, description='描述')
    description: Optional[str] = Field(None, description='描述')
    domain: Optional[str] = Field(None, description='域名')


class GoodCreate(GoodBase):
    pass


class Good(GoodBase):
    id: Optional[int] = Field(0, description='自增ID')

    good_code: Optional[str] = Field(None, description='商品编码')

    user_id: Optional[int] = Field(None, description='添加人')

    created_at: Annotated[Optional[datetime], Optional[str]] = None
    updated_at: Annotated[Optional[datetime], Optional[str]] = None


class GoodOut(BaseApiOut):
    data: Annotated[Good, None] = None


class GoodListOut(BaseApiListOut):
    data: Annotated[List[Good], None] = None
